package e.odbo.data.mock;

import com.openbravo.data.loader.serialize.Datas;
import e.odbo.data.generator.Generator;
import e.odbo.data.generator.I_Generator;
import e.odbo.data.model.*;
import e.odbo.data.util.TableUtils;

public class DemoDatabase_1_0_2 extends DataBase {
    public static I_Generator<Integer> ID_INT=Generator.INCREMENT_INT(0);

    public DemoDatabase_1_0_2() {
        super("demoDatabase","1.0.2");
        this.addTable(TableMock.getAllTables());
        this.registerMigration(migrationFromV1_0_0);
        migrationFromV1_0_0.add(TableMock.getDemo("demo6"))
        .add("demo", Column.c("aliteColumn", ColumnType.VARCHAR(20))
             ,Column.c("valuea",ColumnType.BOOLEAN,"是Boolean"))
          .addIndex(new Index("demo2","col4"));
        TableData demo1TableData=TableData.C("demo1","ID","name","age","sex")
                .types(Datas.INT , Datas.STRING , Datas.INT , Datas.BOOLEAN);
             //types: Integer(PK) , String , Integer , Boolean;
        demo1TableData.value(ID_INT.generator(),"name2",20,false)
                .value(ID_INT.generator(),"dfads",6,true)
                .value(ID_INT.generator(),"asdfsa",35,false)
                .value(ID_INT.generator(),"asdfasf",7,true)
                .value(ID_INT.generator(),"as",16,false)
                .value(ID_INT.generator(),"asf",11,false)
                .value(ID_INT.generator(),"nasdfme2",68,false)
                .value(ID_INT.generator(),"naasfme2",8,false);
        migrationFromV1_0_0.addData(demo1TableData);
        initData();
    }

    public void initData(){
        TableData demo1TableData=TableData.C("demo1","ID","name","age","sex")
                .types(Datas.INT , Datas.STRING , Datas.INT , Datas.BOOLEAN);
        //types: Integer(PK) , String , Integer , Boolean;
        demo1TableData.value(ID_INT.generator(),"name2",20,false)
                .value(ID_INT.generator(),"dfads",6,true)
                .value(ID_INT.generator(),"asdfsa",35,false)
                .value(ID_INT.generator(),"asdfasf",7,true)
                .value(ID_INT.generator(),"as",16,false)
                .value(ID_INT.generator(),"asf",11,false)
                .value(ID_INT.generator(),"nasdfme2",68,false)
                .value(ID_INT.generator(),"naasfme2",8,false);
        this.addData(demo1TableData);
    }

    Migration migrationFromV1_0_0=new Migration("1.0.0","1.0.2").comment("这是一个试例，见到我就对了。。");

    public static void main(String[] ages){
        TableUtils.printTableDataStruct(TableMock.getDemoWithComment());
    }
}
